package com.lynn.salary.web.action;

import com.lynn.salary.dto.AccessorySearchDTO;
import com.lynn.salary.dto.ArticleSearchDTO;
import com.lynn.salary.dto.SearchDTO;
import com.lynn.salary.dto.SubjectSearchDTO;
import com.lynn.salary.dto.UserSearchDTO;
import com.lynn.salary.pojo.FeedBack;
import com.lynn.salary.util.Cache;

public class SearchAction extends BaseAction {

	private UserSearchDTO userSearchDTO;
	private ArticleSearchDTO articleSearchDTO;
	private SubjectSearchDTO subjectSearchDTO;
	private AccessorySearchDTO accessorySearchDTO; 
	private FeedBack feedBack;
	private String searchTag;
	private String rel;

	public String forUser() {
		return forModule(userSearchDTO, "allUser");
	}

	public String forArticle() {
		return forModule(articleSearchDTO, "seeAllArticle");
	}
	
	public String forSubject() {
		return forModule(subjectSearchDTO, "allSubject");
	}
	
	public String forSubjectComment() {
		return forModule(subjectSearchDTO, "allSubjectComment");
	}
	public String forAccessory() {
		return forModule(accessorySearchDTO, "allAccessory");
	}
	private String forModule(SearchDTO dto, String rel) {
		System.out.println("searchTag ==> " + searchTag);
		System.out.println("dto ==> " + dto);
		Cache.instance.cacheSearchCondition(searchTag, dto);

		feedBack = new FeedBack();
		feedBack.setStatusCode("200");

		feedBack.setMessage("已过滤,您可以点击对话窗口上的<取消>按钮取消过滤");

		feedBack.setRel("");
		feedBack.setNavTabId(rel);
		feedBack.setForwardUrl("");
		feedBack.setCallbackType("");

		return "feedback";
	}

	public String remove() {
		System.out.println("remove action...");
		System.out.println("remove searchTag ==> " + searchTag);
		Cache.instance.getSearchConditionByTag(searchTag, true);

		feedBack = new FeedBack();
		feedBack.setStatusCode("200");

		feedBack.setMessage("已取消过滤");

		feedBack.setRel(rel);
		feedBack.setNavTabId(rel);
		feedBack.setForwardUrl("");
		feedBack.setCallbackType("");

		return "feedback";
	}

	public UserSearchDTO getUserSearchDTO() {
		return userSearchDTO;
	}

	public void setUserSearchDTO(UserSearchDTO userSearchDTO) {
		this.userSearchDTO = userSearchDTO;
	}

	public FeedBack getFeedBack() {
		return feedBack;
	}

	public void setFeedBack(FeedBack feedBack) {
		this.feedBack = feedBack;
	}

	public String getSearchTag() {
		return searchTag;
	}

	public void setSearchTag(String searchTag) {
		this.searchTag = searchTag;
	}

	public ArticleSearchDTO getArticleSearchDTO() {
		return articleSearchDTO;
	}

	public void setArticleSearchDTO(ArticleSearchDTO articleSearchDTO) {
		this.articleSearchDTO = articleSearchDTO;
	}

	public SubjectSearchDTO getSubjectSearchDTO() {
		return subjectSearchDTO;
	}

	public void setSubjectSearchDTO(SubjectSearchDTO subjectSearchDTO) {
		this.subjectSearchDTO = subjectSearchDTO;
	}

	public String getRel() {
		return rel;
	}

	public void setRel(String rel) {
		this.rel = rel;
	}

	public AccessorySearchDTO getAccessorySearchDTO() {
		return accessorySearchDTO;
	}

	public void setAccessorySearchDTO(AccessorySearchDTO accessorySearchDTO) {
		this.accessorySearchDTO = accessorySearchDTO;
	}

}
